﻿@using S4Store.Domain
@{
    S4Store.Domain.Administrator CurrentUser = (S4Store.Domain.Administrator)ViewBag.CurrentUser;
}
@model S4Store.Models.Tb.ByPersonModel
@{
    Layout = null;
    ViewBag.Title = "ByPerson";

    S4Store.Models.Chart.Line ChartModel = new S4Store.Models.Chart.Line();
    //ChartModel.Name = "登记客户";
    ChartModel.YAxis = "保险率";
    ChartModel.Width = 500;
    ChartModel.Height = 300;
    foreach (var m in Model.ChartReports)
    {
        ChartModel.XAxis.Add(m.Month + "月");
    }
    S4Store.Models.Chart.ChartSeries series1 = new S4Store.Models.Chart.ChartSeries();
    series1.Name = "保险率目标";
    foreach (var m in Model.ChartReports)
    {
        series1.Data.Add(m.SellerPerformanceStandard.BXLV);
    }
    ChartModel.Serieses.Add(series1);

    S4Store.Models.Chart.ChartSeries series2 = new S4Store.Models.Chart.ChartSeries();
    series2.Name = "实际保险率";
    foreach (var m in Model.ChartReports)
    {
        series2.Data.Add(m.BXLV);
    }
    ChartModel.Serieses.Add(series2);
    ChartModel.Colors = new List<string> { S4Store.Models.Chart.Color.Green, S4Store.Models.Chart.Color.Blue };
}
<div style="height:100%; overflow:auto">
<div style=" width:100%; height:30px; background:#E5EDEF">
    <div ratio="#25" class="panelBar" style="height: 25px;">
	<ul class="toolBar">
	@if (
                           CurrentUser.Position == S4Store.Domain.Position.SystemManager ||
                           CurrentUser.Position == S4Store.Domain.Position.SaleTutors ||
                           CurrentUser.Position == S4Store.Domain.Position.DealerTutors
                           )
		{
		<li class="historyrecord"><a  backtype="html" href="@Url.Action("AddImproveGuide", "ImproveGuide", new { SellerId = Model.Seller.Id ,referdesc="销售管理>新车投保业绩动态>人员查询"})" target="dialog" width="60%"><span class="icon edit">填写改善指导建议</span></a></li>
		}
	</ul>
</div>
</div>
<table>
    <tr>
    <td valign="top">
    <div style="margin:10px">@Model.BarModel.Month.ToString("yyyy年M月") KPI数据</div>
    <table  class="reporttable"  style="border-collapse:collapse;">     
<tr height="198" style="height:148.5pt" class="vtr">
    <th width="60"  class="inputedheader"><div>销售顾问姓名</div></th>
    <th width="85"  class="inputedheader"><div>车型</div></th>
    <th   class="inputedheader"><div>本月交车数</div></th>
    <th   class="inputedheader"><div>新车保险投保数</div></th>
    <th   class="inputedheader"><div>保险销售额(万)</div></th>
    <th   class="calculated"><div>当月保险率</div></th>
    <th   class="calculated"><div>平均单车保险额(万）</div></th>
</tr>

@{
    var brands = Model.SellerKpiPersonBodyModel.GetCarBrands(Model.Seller);
    int i=0;
    foreach (var brand in brands)
    {
        var report = Model.SellerKpiPersonBodyModel.GetReportByBrandAndSeller(Model.Seller, brand);
        <tr height="26" style="height:19.5pt" class="xl65">
                        @if (i++ == 0)
                        {
                            <td rowspan="@brands.Count">@Model.Seller.Name</td>
                        }
                        <td>@brand.Name</td>
                        <td>@report.JCS</td>
                        <td>@report.XCBXTBS</td>
                        <td>@report.BXXSE</td>
                        <td class="calculated" @S4Store.Utils.GetBgColor(report.BXLVDiff > 0)>@report.BXLV.toInt()%</td>
                        <td class="calculated" @S4Store.Utils.GetBgColor(report.PJDCBXE >= report.SellerPerformanceStandard.PJDCBXE)>@report.PJDCBXE.toInt()</td>
                    </tr>
    }
}

<tr>
    <th colspan="2">合计</th>
    <td>@Model.SellerPersonReport.JCS</td>
    <td>@Model.SellerPersonReport.XCBXTBS</td>
    <td>@Model.SellerPersonReport.BXXSE</td>
    <td class="calculated" @S4Store.Utils.GetBgColor(Model.SellerPersonReport.BXLVDiff >= 0)>@Model.SellerPersonReport.BXLV.toInt()%</td>
    <td class="calculated" @S4Store.Utils.GetBgColor(Model.SellerPersonReport.PJDCBXE >= Model.SellerPersonReport.PJDCBXE)>@Model.SellerPersonReport.PJDCBXE.toInt()</td>
        </table>
    </td>
    <td valign="top">
    <div style=" width:100%; height:30px; background:#E5EDEF">
    <div style=" padding:5px 10px;width:100%; ">
        <form action="@Url.Action("ByPerson", "Tb")">        
            @Html.Partial("YmSeleter", new S4Store.Models.YmList { Start = new DateTime(2013,1,1), End = DateTime.Now, Current = Model.BarModel.Start, Name = "Start" })
            -
            @Html.Partial("YmSeleter", new S4Store.Models.YmList { Start = new DateTime(2013, 1, 1), End = DateTime.Now, Current = Model.BarModel.End, Name = "End" })
            <input type="hidden" name="SearchSellerId" value="@Model.Seller.Id" />
          <input type="button" value="查询" class="reportsubmit" />
        </form>
    </div>
</div>
@Html.Partial("../Chart/Line", ChartModel)
    </td>
    </tr>
</table>
        
</div>

